"use strict";
/* Controllers */
app.controller("DetailController", ['$scope', '$location', '$rootScope', '$routeParams', 'detailService',
    function ($scope, $location, $rootScope, $routeParams, detailService) {
    var vm = $scope.vm = {};
    vm.p = {};
    vm.result = {};
    var errorFn = function (result) {
        alert(result);
    };

    // 数据地图仅仅到数据域（主题域）最细到主题和表
    vm.conf = [];
    $scope.queryItems = function(id) {
        $scope.detailMetricServiceEntity(id);
    };

    $scope.detailMetricServiceEntity = function (id) {
        var vm = $scope.vm;
        vm.result.ms = "...";
        var params = {'id': id};
        var procFn = function (response) {
            if ("000" !== response.code) {
                alert(response.message);
                return ;
            }
            vm.result.ms = response.ms;
            var data = response.data;
            if (data == null) return;
            vm.result.data = data[0];
            $('#tbl').bootstrapTable('load', vm.result.data);
        };

       detailService.detailMetricServiceEntity(params, procFn, errorFn);

    };


    $scope.initializeController = function () {
        vm.result.ms = '';
        $scope.detailMetricServiceEntity($routeParams.id);
    };
    $scope.initializeController();
}]);


/* Services */
app.service('detailService', ['ajaxService', function (ajaxService) {
    this.detailMetricServiceEntity = function (params, successFunction, errorFunction) {
       ajaxService.AjaxPost(params, "/star/api/basic-service/v1/data_content/detailMetricServiceEntity.do", successFunction, errorFunction);
    };


}]);



